﻿<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class xembangluong_Model extends Model {

    function __construct()
    {
        parent::__construct();
    }

    public function SELECT_TRANG_THAI_THANG_LUONG($arr_filter){
        $P_THANG =  $arr_filter['cbx_THANG'];
        $P_NAM =$arr_filter['cbx_NAM'];
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG.SELECT_TRANG_THAI_THANG_LUONG(:CUR,$P_THANG,$P_NAM);END;",'CUR');
    }
     public function SELECT_BANG_LUONG($arr_filter){
        $P_THANG =  $arr_filter['cbx_THANG'];
        $P_NAM =$arr_filter['cbx_NAM'];
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG.SELECT_BANG_LUONG(:CUR,$P_THANG,$P_NAM);END;",'CUR');
    }
     public function SELECT_BANG_LUONG2($P_THANG,$P_NAM){
        return $this->db->ExecuteCursor("BEGIN QUANLYLUONG.SELECT_BANG_LUONG(:CUR,$P_THANG,$P_NAM);END;",'CUR');
    }
    public function tinh_luong(){
        $P_NGUOI_CAP_NHAT= Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
        $P_THANG = get_post_var('cbx_THANG',0);
        $P_NAM = get_post_var('cbx_NAM',0);
        $P_THANG_HIEN_TAI = date(m);
        $P_NAM_HIEN_TAI = date(Y);
        $stmt = $this->db->PrepareSP("BEGIN QUANLYLUONG.TINH_BANG_LUONG(:P_VAL,:P_THANG,:P_NAM,:P_THANG_HIEN_TAI,:P_NAM_HIEN_TAI);END;");
        $this->db->OutParameter($stmt,$P_VAL,'P_VAL');
        $this->db->InParameter($stmt,$P_THANG,'P_THANG');
        $this->db->InParameter($stmt,$P_NAM,'P_NAM');
        $this->db->InParameter($stmt,$P_THANG_HIEN_TAI,'P_THANG_HIEN_TAI');
        $this->db->InParameter($stmt,$P_NAM_HIEN_TAI,'P_NAM_HIEN_TAI');
        $chaythutuc = $this->db->Execute($stmt);
        if ($chaythutuc){
          if ($P_VAL == 'THANH_CONG'){
              $this->exec_done($this->goback_url);
          }else{
               $this->exec_fail($this->goback_url, $P_VAL);
               return;
          }
        }else{
            echo $this->db->ErrorMsg();
            $this->exec_fail($this->goback_url,'Lỗi database');
            return;
        }
    }
    public function capnhat_luong(){
        $P_NGUOI_CAP_NHAT= Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
        $P_THANG = get_post_var('cbx_THANG',0);
        $P_NAM = get_post_var('cbx_NAM',0);
        $P_THANG_HIEN_TAI = date(m);
        $P_NAM_HIEN_TAI = date(Y);
        $stmt = $this->db->PrepareSP("BEGIN QUANLYLUONG.CAP_NHAT_BANG_LUONG(:P_VAL,:P_THANG,:P_NAM,:P_THANG_HIEN_TAI,:P_NAM_HIEN_TAI);END;");
        $this->db->OutParameter($stmt,$P_VAL,'P_VAL');
        $this->db->InParameter($stmt,$P_THANG,'P_THANG');
        $this->db->InParameter($stmt,$P_NAM,'P_NAM');
        $this->db->InParameter($stmt,$P_THANG_HIEN_TAI,'P_THANG_HIEN_TAI');
        $this->db->InParameter($stmt,$P_NAM_HIEN_TAI,'P_NAM_HIEN_TAI');
        $chaythutuc = $this->db->Execute($stmt);
        if ($chaythutuc){
          if ($P_VAL == 'THANH_CONG'){
              $this->exec_done($this->goback_url);
          }else{
               $this->exec_fail($this->goback_url, $P_VAL);
               return;
          }
        }else{
            echo $this->db->ErrorMsg();
            $this->exec_fail($this->goback_url,'Lỗi database');
            return;
        }
    }
    public function khoa_luong(){
        $P_NGUOI_CAP_NHAT= Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
        $P_THANG = get_post_var('cbx_THANG',0);
        $P_NAM = get_post_var('cbx_NAM',0);
        $P_THANG_HIEN_TAI = date(m);
        $P_NAM_HIEN_TAI = date(Y);
        $stmt = $this->db->PrepareSP("BEGIN QUANLYLUONG.KHOA_BANG_LUONG(:P_VAL,:P_THANG,:P_NAM,:P_THANG_HIEN_TAI,:P_NAM_HIEN_TAI);END;");
        $this->db->OutParameter($stmt,$P_VAL,'P_VAL');
        $this->db->InParameter($stmt,$P_THANG,'P_THANG');
        $this->db->InParameter($stmt,$P_NAM,'P_NAM');
        $this->db->InParameter($stmt,$P_THANG_HIEN_TAI,'P_THANG_HIEN_TAI');
        $this->db->InParameter($stmt,$P_NAM_HIEN_TAI,'P_NAM_HIEN_TAI');
        $chaythutuc = $this->db->Execute($stmt);
        if ($chaythutuc){
          if ($P_VAL == 'THANH_CONG'){
              $this->exec_done($this->goback_url);
          }else{
               $this->exec_fail($this->goback_url, $P_VAL);
               return;
          }
        }else{
            echo $this->db->ErrorMsg();
            $this->exec_fail($this->goback_url,'Lỗi database');
            return;
        }
    }
}